/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.business.account.facade.order.freeze;

import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import info.peigen.hotpot.business.account.facade.enums.AccountFreezeType;
import info.peigen.hotpot.business.account.facade.order.base.AbstractAccountServiceOrder;
import info.peigen.hotpot.common.core.lang.money.Money;
import jakarta.validation.constraints.NotEmpty;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

/**
 * <b>(FreezeAmountOrder)</b>
 * 冻结 账户资金
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/12
 */
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class FreezeAmountOrder extends AbstractAccountServiceOrder {
    /** 账户ID */
    @NotEmpty
    String accountId;
    /** 交易D */
    String tradeId;
    /** 冻结类型 */
    @Builder.Default
    AccountFreezeType type   = AccountFreezeType.System;
    /** 冻结金额 */
    @Builder.Default
    Money             amount = Money.zero();
    /** 描述 */
    @NotEmpty
    String            reason;
    /** BOPS操作员 */
    String bopsOperatorId;

    @Override
    public void check() {
        super.check();
        if (type == AccountFreezeType.Ops) {
            Assert.isTrue(StrUtil.isNotEmpty(bopsOperatorId));
        }
    }
}
